// 多态案例2 - 制作饮品

#include <iostream>
using namespace std;

class AbstractDrinking
{
public:
    // 烧水
    virtual void boil() = 0;
    // 冲泡
    virtual void brew() = 0;
    // 倒入杯中
    virtual void pour_in_cup() = 0;
    // 加入辅料
    virtual void put_something() = 0;
    // 规定流程
    void make_dring()
    {
        boil();
        brew();
        pour_in_cup();
        put_something();
    }
};

class Coffee : public AbstractDrinking
{
public:
    void boil()
    {
        cout << "boil nongfu moutain spring..." << endl;
    }
    void brew()
    {
        cout << "brew coffee..." << endl;
    }
    void pour_in_cup()
    {
        cout << "coffee put in to cup..." << endl;
    }
    void put_something()
    {
        cout << "put milk in to coffed" << endl;
    }
};

class Tea : public AbstractDrinking
{
    void boil()
    {
        cout << "boil water..." << endl;
    }
    void brew()
    {
        cout << "brew tea..." << endl;
    }
    void pour_in_cup()
    {
        cout << "tea put in to cup..." << endl;
    }
    void put_something()
    {
        cout << "put sugar in to coffed" << endl;
    }
};

// 业务函数
void do_work(AbstractDrinking *drink)
{
    drink->make_dring();
    delete drink;
}

int main()
{
    // 做咖啡
    do_work(new Coffee);
    cout << "--------------" << endl;
    do_work(new Tea);
    return 0;
}
